package com.example.zhixu.myapp2;

import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import java.io.IOException;

public class MusicActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_music);

    }

    public void play(View view) {
        Intent intent = new Intent();
//        intent.setClass(this, MusicActivity.class);
        intent.setAction("music");
        intent.setPackage(this.getPackageName());
        intent.putExtra("action", "play");
        startService(intent);
    }

    public void pause(View view) {
        Intent intent = new Intent();
//        intent.setClass(this, MusicActivity.class);
        intent.setAction("music");
        intent.setPackage(this.getPackageName());
        intent.putExtra("action", "pause");
        startService(intent);
    }
}
